var _n81;
var cc__extends = __extends;
var cc__importDefault = __importDefault;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var a;
var cc_zqcc_frameNamespace = require("zqcc_frameNamespace");
var zqcc_frameNamespace = cc__importDefault(cc_zqcc_frameNamespace);
var $1$zqcc_dialog = require("zqcc_dialog");
var c = cc__importDefault($1$zqcc_dialog);
var $1$Fuwu = require("Fuwu");
var l = cc__importDefault($1$Fuwu);
var $1$gameList = require("gameList");
var u = cc__importDefault($1$gameList);
var $1$gameListNew = require("gameListNew");
var p = cc__importDefault($1$gameListNew);
var $1$gameSettingPage = require("gameSettingPage");
var d = cc__importDefault($1$gameSettingPage);
var $1$getPowerPage = require("getPowerPage");
var h = cc__importDefault($1$getPowerPage);
var $1$infinityPowerPage = require("infinityPowerPage");
var f = cc__importDefault($1$infinityPowerPage);
var $1$loadingPage = require("loadingPage");
var y = cc__importDefault($1$loadingPage);
var $1$message = require("message");
var g = cc__importDefault($1$message);
var $1$zqcc_pageBase = require("zqcc_pageBase");
var v = cc__importDefault($1$zqcc_pageBase);
var $1$PathTips = require("PathTips");
var m = cc__importDefault($1$PathTips);
var $1$PifuPage = require("PifuPage");
var _ = cc__importDefault($1$PifuPage);
var $1$selectArea = require("selectArea");
var S = cc__importDefault($1$selectArea);
var $1$SignIn = require("SignIn");
var b = cc__importDefault($1$SignIn);
var $1$tianjiazhuomian = require("tianjiazhuomian");
var w = cc__importDefault($1$tianjiazhuomian);
var $1$tishi = require("tishi");
var P = cc__importDefault($1$tishi);
var $1$Tujian = require("Tujian");
var O = cc__importDefault($1$Tujian);
var $1$Yinsi = require("Yinsi");
var C = cc__importDefault($1$Yinsi);
var $1$zhutiList = require("zhutiList");
var N = cc__importDefault($1$zhutiList);
var $zqcc_OverallSystem = require("zqcc_OverallSystem");
var $1$userService = require("userService");
var M = cc__importDefault($1$userService);
(function (t) {
  t[t.portrait = 0] = "portrait";
  t[t.landscape = 1] = "landscape";
})(a || (a = {}));
var def_uiService = function (t) {
  function _ctor() {
    var e = t.call(this) || this;
    e._serviceName = "ui服务";
    e.uiRoot = null;
    e._pageList = [];
    e.framePagePrefix = "";
    e._deviceOrientation = a.landscape;
    e.pathTips = null;
    e.loadingPage = null;
    e._Initialize();
    return e;
  }
  cc__extends(_ctor, t);
  _ctor.prototype._Initialize = function () {
    t.prototype._Initialize.call(this);
  };
  Object.defineProperty(_ctor.prototype, "UIRoot", {
    get() {
      return this.uiRoot;
    },
    enumerable: false,
    configurable: true
  });
  _ctor.prototype._setUIRoot = function (t) {
    this.uiRoot = t;
  };
  Object.defineProperty(_ctor.prototype, "deviceOrientation", {
    get() {
      return this._deviceOrientation;
    },
    set(t) {
      this._deviceOrientation = t;
    },
    enumerable: false,
    configurable: true
  });
  _ctor.prototype.openPageInit = function (t, e, o) {
    undefined === e && (e = false);
    undefined === o && (o = true);
    if (e) {
      this._pageList.forEach(function (t) {
        t.onlyClose();
      });
      this._pageList = [];
    }
    for (this._pageList.push(t); o && this._pageList.length > 2;) {
      this._pageList.shift().onlyClose();
    }
    for (var n = 0; n < this._pageList.length; n++) {
      this._pageList[n].id = n;
    }
    console.log("添加页面入表 >>>> ", t.pageName);
  };
  _ctor.prototype.deletePageRecord = function (t) {
    this._pageList.splice(t, 1);
    for (var e = 0; e < this._pageList.length; e++) {
      this._pageList[e].id = e;
    }
  };
  _ctor.prototype._closeCurrScenePage = function () {
    this._pageList.forEach(function (t) {
      t.node && t.node.destroy();
    });
    this._pageList = [];
  };
  _ctor.prototype.showDialog = function (t, e, o, n, i, r, a, zqcc_frameNamespace, l, u) {
    var p = this;
    undefined === e && (e = "温馨提示");
    undefined === i && (i = false);
    undefined === r && (r = 0);
    undefined === zqcc_frameNamespace && (zqcc_frameNamespace = false);
    undefined === l && (l = true);
    n = n || this.uiRoot;
    var d = this.framePagePrefix + "zqcc_dialog";
    this.loadPagePrefab(d).then(function (d) {
      var h = cc.instantiate(d);
      var f = h.getComponent(c.default);
      f.zqcc_setDate(t, e, o, i, r, a, u);
      p.openPageInit(f, zqcc_frameNamespace, l);
      n.addChild(h);
    });
  };
  _ctor.prototype.showSettingPage = function (t, e, o, n) {
    var i = this;
    undefined === t && (t = 0);
    undefined === o && (o = false);
    undefined === n && (n = true);
    e = e || this.uiRoot;
    var r = this.framePagePrefix + "gameSetting";
    this.loadPagePrefab(r).then(function (r) {
      var a = cc.instantiate(r);
      var zqcc_frameNamespace = a.getComponent(d.default);
      zqcc_frameNamespace.showBtn(t);
      i.openPageInit(zqcc_frameNamespace, o, n);
      e.addChild(a);
    });
  };
  _ctor.prototype.showUsePropPage = function (t, e, o, n) {
    var i = this;
    undefined === o && (o = false);
    undefined === n && (n = true);
    e = e || this.uiRoot;
    this.loadPrefab("link", "prefabs/UsePropPage").then(function (r) {
      var a = cc.instantiate(r);
      var zqcc_frameNamespace = a.getComponent(v.default);
      zqcc_frameNamespace.initData(t);
      i.openPageInit(zqcc_frameNamespace, o, n);
      e.addChild(a);
    });
  };
  _ctor.prototype.showRevivePage = function (t, e, o) {
    var n = this;
    undefined === e && (e = true);
    undefined === o && (o = false);
    this.loadPrefab("link", "prefabs/RevivePage").then(function (i) {
      var r = cc.instantiate(i);
      var a = r.getComponent(v.default);
      a.initData(t);
      n.openPageInit(a, e, o);
      n.uiRoot.addChild(r);
    });
  };
  _ctor.prototype.showTipsPage = function (t, e, o) {
    var n = this;
    undefined === e && (e = false);
    undefined === o && (o = true);
    t = t || this.uiRoot;
    var i = this.framePagePrefix + "tishi";
    this.loadPagePrefab(i).then(function (i) {
      var r = cc.instantiate(i);
      var a = r.getComponent(P.default);
      n.openPageInit(a, e, o);
      t.addChild(r);
    });
  };
  _ctor.prototype.showYinsiPage = function (t, e, o) {
    var n = this;
    undefined === e && (e = false);
    undefined === o && (o = true);
    t = t || this.uiRoot;
    var i = this.framePagePrefix + "Yinsi";
    this.loadPagePrefab(i).then(function (i) {
      var r = cc.instantiate(i);
      var a = r.getComponent(C.default);
      n.openPageInit(a, e, o);
      t.addChild(r);
    });
  };
  _ctor.prototype.showtianjiazhuomianPage = function (t, e, o) {
    var n = this;
    undefined === e && (e = false);
    undefined === o && (o = true);
    t = t || this.uiRoot;
    var i = this.framePagePrefix + "tianjiazhuomian";
    this.loadPagePrefab(i).then(function (i) {
      var r = cc.instantiate(i);
      var a = r.getComponent(w.default);
      n.openPageInit(a, e, o);
      t.addChild(r);
    });
  };
  _ctor.prototype.showFuwuPage = function (t, e, o) {
    var n = this;
    undefined === e && (e = false);
    undefined === o && (o = true);
    t = t || this.uiRoot;
    var i = this.framePagePrefix + "Fuwu";
    this.loadPagePrefab(i).then(function (i) {
      var r = cc.instantiate(i);
      var a = r.getComponent(l.default);
      n.openPageInit(a, e, o);
      t.addChild(r);
    });
  };
  _ctor.prototype.showGameListNewPage = function (t, e, o, n) {
    var i = this;
    undefined === o && (o = false);
    undefined === n && (n = true);
    e = e || this.uiRoot;
    var r = this.framePagePrefix + "gameListNew";
    this.loadPagePrefab(r).then(function (r) {
      var a = cc.instantiate(r);
      var zqcc_frameNamespace = a.getComponent(p.default);
      zqcc_frameNamespace.setCloseDoFun(t);
      i.openPageInit(zqcc_frameNamespace, o, n);
      e.addChild(a);
    });
  };
  _ctor.prototype.showPifuPage = function (t, e, o, n) {
    var i = this;
    undefined === o && (o = false);
    undefined === n && (n = true);
    e = e || this.uiRoot;
    var r = this.framePagePrefix + "PifuPage";
    this.loadPagePrefab(r).then(function (r) {
      var a = cc.instantiate(r);
      var zqcc_frameNamespace = a.getComponent(_.default);
      zqcc_frameNamespace.setCloseDoFun(t);
      i.openPageInit(zqcc_frameNamespace, o, n);
      e.addChild(a);
    });
  };
  _ctor.prototype.showOverPage = function (t, e, o, n, i) {
    var r = this;
    undefined === n && (n = false);
    undefined === i && (i = true);
    o = o || this.uiRoot;
    var a = this.framePagePrefix + "OverPage";
    this.loadPagePrefab(a).then(function (a) {
      var zqcc_frameNamespace = cc.instantiate(a);
      var c = zqcc_frameNamespace.getComponent(v.default);
      r.openPageInit(c, n, i);
      c.setCloseDoFun(e);
      c.initData(t);
      o.addChild(zqcc_frameNamespace);
    });
  };
  _ctor.prototype.showPathTips = function (t, e, o) {
    var n = this;
    undefined === e && (e = false);
    undefined === o && (o = false);
    t = t || this.uiRoot;
    var i = this.framePagePrefix + "PathTips";
    if (this.pathTips) {
      this.pathTips.active = !this.pathTips.active;
    } else {
      this.loadPagePrefab(i).then(function (t) {
        var e = cc.instantiate(t);
        e.getComponent(m.default);
        n.pathTips = e;
        n.uiRoot.addChild(e);
      });
    }
  };
  _ctor.prototype.showTyOverPage = function (t, e, o, n, i) {
    var r = this;
    undefined === n && (n = false);
    undefined === i && (i = true);
    o = o || this.uiRoot;
    var a = this.framePagePrefix + "TyOverPage";
    this.loadPagePrefab(a).then(function (a) {
      var zqcc_frameNamespace = cc.instantiate(a);
      var c = zqcc_frameNamespace.getComponent(v.default);
      r.openPageInit(c, n, i);
      c.setCloseDoFun(e);
      c.initData(t);
      o.addChild(zqcc_frameNamespace);
    });
  };
  _ctor.prototype.showSelectDiQuPage = function (t, e, o, n) {
    var i = this;
    undefined === o && (o = false);
    undefined === n && (n = true);
    e = e || this.uiRoot;
    var r = this.framePagePrefix + "selectArea";
    this.loadPagePrefab(r).then(function (r) {
      var a = cc.instantiate(r);
      var zqcc_frameNamespace = a.getComponent(S.default);
      zqcc_frameNamespace.pageData = t;
      i.openPageInit(zqcc_frameNamespace, o, n);
      e.addChild(a);
    });
  };
  _ctor.prototype.showRankingListPage = function (t, e, o, n) {
    var i = this;
    undefined === o && (o = false);
    undefined === n && (n = true);
    e = e || this.uiRoot;
    var r = this.framePagePrefix + "rankingList";
    this.loadPagePrefab(r).then(function (t) {
      var r = cc.instantiate(t);
      var a = r.getComponent(v.default);
      i.openPageInit(a, o, n);
      e.addChild(r);
    });
  };
  _ctor.prototype.showGameListPage = function (t, e, o, n) {
    var i = this;
    undefined === o && (o = false);
    undefined === n && (n = true);
    e = e || this.uiRoot;
    var r = this.framePagePrefix + "gameList";
    this.loadPagePrefab(r).then(function (r) {
      var a = cc.instantiate(r);
      var zqcc_frameNamespace = a.getComponent(u.default);
      zqcc_frameNamespace.setCloseDoFun(t);
      i.openPageInit(zqcc_frameNamespace, o, n);
      e.addChild(a);
    });
  };
  _ctor.prototype.showZhutiListPage = function (t, e, o, n) {
    var i = this;
    undefined === o && (o = false);
    undefined === n && (n = true);
    e = e || this.uiRoot;
    var r = this.framePagePrefix + "zhutiList";
    this.loadPagePrefab(r).then(function (t) {
      var r = cc.instantiate(t);
      var a = r.getComponent(N.default);
      i.openPageInit(a, o, n);
      e.addChild(r);
    });
  };
  _ctor.prototype.showSignInPage = function (t, e, o, n) {
    var i = this;
    undefined === o && (o = false);
    undefined === n && (n = true);
    e = e || this.uiRoot;
    var r = this.framePagePrefix + "SignIn";
    this.loadPagePrefab(r).then(function (t) {
      var r = cc.instantiate(t);
      var a = r.getComponent(b.default);
      i.openPageInit(a, o, n);
      e.addChild(r);
    });
  };
  _ctor.prototype.showTujianPage = function (t, e, o, n) {
    var i = this;
    undefined === o && (o = false);
    undefined === n && (n = true);
    e = e || this.uiRoot;
    var r = this.framePagePrefix + "Tujian";
    this.loadPagePrefab(r).then(function (t) {
      var r = cc.instantiate(t);
      var a = r.getComponent(O.default);
      i.openPageInit(a, o, n);
      e.addChild(r);
    });
  };
  _ctor.prototype.showInfinityPage = function (t, e, o, n, i) {
    var r = this;
    undefined === n && (n = false);
    undefined === i && (i = true);
    if (0 != Number($zqcc_OverallSystem.sers().localStorageSrv.get(M.default.infinityPowerModel))) {
      t && t(false);
    } else {
      o = o || this.uiRoot;
      var a = this.framePagePrefix + "infinityPower";
      this.loadPagePrefab(a).then(function (a) {
        var zqcc_frameNamespace = cc.instantiate(a);
        var c = zqcc_frameNamespace.getComponent(f.default);
        c.setCloseDoFun(t);
        c.setCloseDoFun2(e);
        r.openPageInit(c, n, i);
        o.addChild(zqcc_frameNamespace);
      });
    }
  };
  _ctor.prototype.showReceiveInfinityPage = function (t, e, o, n) {
    var i = this;
    undefined === o && (o = false);
    undefined === n && (n = true);
    e = e || this.uiRoot;
    var r = this.framePagePrefix + "receiveInfinit";
    this.loadPagePrefab(r).then(function (r) {
      var a = cc.instantiate(r);
      var zqcc_frameNamespace = a.getComponent(v.default);
      i.openPageInit(zqcc_frameNamespace, o, n);
      zqcc_frameNamespace.setCloseDoFun(t);
      e.addChild(a);
    });
  };
  _ctor.prototype.showUserGetPowerPage = function (t, e, o, n) {
    var i = this;
    undefined === o && (o = false);
    undefined === n && (n = false);
    e = e || this.uiRoot;
    var r = this.framePagePrefix + "getPower";
    this.loadPagePrefab(r).then(function (r) {
      var a = cc.instantiate(r);
      var zqcc_frameNamespace = a.getComponent(h.default);
      zqcc_frameNamespace.setCloseDoFun(t);
      i.openPageInit(zqcc_frameNamespace, o, n);
      e.addChild(a);
    });
  };
  _ctor.prototype.showMessage = function (t, e, o, n, i) {
    undefined === e && (e = 2);
    o = o || this.uiRoot;
    this.loadPagePrefab("message").then(function (r) {
      var a = cc.instantiate(r);
      a.getComponent(g.default).setData(t, e, n, i);
      o.addChild(a);
      a.zIndex = cc.macro.MAX_ZINDEX;
    });
  };
  _ctor.prototype.showLoding = function (t, e) {
    var o = this;
    undefined === t && (t = false);
    undefined === e && (e = null);
    this.hideLoding();
    if (this.loadingPage && this.loadingPage.node.parent) {
      this.loadingPage.node.active = true;
    } else {
      this.loadPagePrefab2("loading").then(function (n) {
        var i = cc.instantiate(n);
        o.loadingPage = i.getComponent(y.default);
        o.uiRoot.addChild(i);
        if (t) {
          o.hideLoding();
          e && e();
        }
      });
    }
  };
  _ctor.prototype.hideLoding = function () {
    null != this.loadingPage && (this.loadingPage.node.active = false);
  };
  _ctor.prototype.loadPagePrefab = function (t) {
    return new Promise(function (e, o) {
      $zqcc_OverallSystem.mgrs().bundleMgr.BundleList.frameBundle.load("prefabs/" + t, cc.Prefab, function (n, i) {
        if (n) {
          console.error("从bundle加载页面预制体出错 :", t, "-----", n);
          return void o();
        }
        e(i);
      });
    });
  };
  _ctor.prototype.loadPagePrefab2 = function (t) {
    return new Promise(function (e, o) {
      $zqcc_OverallSystem.mgrs().bundleMgr.BundleList.loadingPage.load("prefabs/" + t, cc.Prefab, function (n, i) {
        if (n) {
          console.error("从bundle加载页面预制体出错 :", t, "-----", n);
          return void o();
        }
        e(i);
      });
    });
  };
  _ctor.prototype.loadPrefab = function (t, e) {
    return new Promise(function (o, n) {
      cc.assetManager.loadBundle(t, function (t, i) {
        if (t) {
          console.error("加载所需bundle失败", t);
          return void n();
        }
        i.load(e, cc.Prefab, function (t, i) {
          if (t) {
            console.error("从bundle加载页面预制体出错 :", e, "-----", t);
            return void n();
          }
          o(i);
        });
      });
    });
  };
  _ctor.prototype.showPage = function (t, e, o, n, i) {
    var r = this;
    undefined === n && (n = true);
    undefined === i && (i = false);
    this.showLoding();
    this.loadPrefab(t, "prefabs/" + e).then(function (t) {
      r.hideLoding();
      var e = cc.instantiate(t);
      var a = e.getComponent(v.default);
      a.initData(o);
      r.openPageInit(a, n, i);
      r.uiRoot.addChild(e);
    }).catch(function () {
      r.hideLoding();
    });
  };
  _ctor.openPageBasicAni = function (t, e) {
    undefined === e && (e = false);
    return new Promise(function (o, n) {
      if (null != t && t.isValid) {
        if (e || t.active) {
          e && (t.active = true);
          t.scale = .01;
          t.opacity = 0;
          return void cc.tween(t).parallel(cc.tween(t).to(.15, {
            opacity: 255
          }), cc.tween(t).to(.2, {
            scale: 1
          }, cc.easeBackOut()), cc.tween(t).by(.2, {
            y: 0
          })).call(function () {
            o();
          }).start();
        } else {
          console.error("openPageBasicAni 节点未激活");
          return void n();
        }
      } else {
        console.error("openPageBasicAni 节点为空 或 不可用");
        return void n();
      }
    });
  };
  _ctor.openPageBasicAni2 = function (t, e) {
    undefined === e && (e = false);
    return new Promise(function (o, n) {
      if (null != t && t.isValid) {
        if (e || t.active) {
          e && (t.active = true);
          t.scale = .01;
          t.opacity = 0;
          t.children[0] && (t.children[0].active = false);
          return void cc.tween(t).parallel(cc.tween(t).to(.15, {
            opacity: 255
          }), cc.tween(t).to(.2, {
            scale: 1
          }, cc.easeBackOut()), cc.tween(t).by(.2, {
            y: 0
          })).call(function () {
            if (t.children[0]) {
              t.children[0].active = true;
              t.children[0].opacity = 0;
              cc.tween(t.children[0]).to(.3, {
                opacity: 180
              }).start();
            }
            o();
          }).start();
        } else {
          console.error("openPageBasicAni 节点未激活");
          return void n();
        }
      } else {
        console.error("openPageBasicAni 节点为空 或 不可用");
        return void n();
      }
    });
  };
  _ctor.closePageBasicAni = function (t, e, o) {
    undefined === e && (e = false);
    undefined === o && (o = false);
    return new Promise(function (n, i) {
      if (null != t && t.isValid) {
        if (t.active) {
          return void cc.tween(t).parallel(cc.tween(t).to(.2, {
            scale: .01
          }, cc.easeInOut(3)), cc.tween(t).by(.2, {
            y: -50
          }), cc.tween(t).delay(.1).to(.1, {
            opacity: 0
          })).call(function () {
            n();
            e && (t.scale = 1);
            o && (t.active = false);
          }).start();
        } else {
          console.error("closePageBasicAni 节点未激活");
          return void i();
        }
      } else {
        console.error("closePageBasicAni 节点为空 或 不可用");
        return void i();
      }
    });
  };
  _ctor.closePageBasicAni2 = function (t, e, o) {
    undefined === e && (e = false);
    undefined === o && (o = false);
    return new Promise(function (n, i) {
      if (null != t && t.isValid) {
        if (t.active) {
          t.children[0] && cc.tween(t.children[0]).to(.1, {
            opacity: 0
          }).call(function () {
            t.children[0].active = false;
          }).start();
          return void cc.tween(t).parallel(cc.tween(t).to(.2, {
            scale: .01
          }, cc.easeInOut(3)), cc.tween(t).by(.2, {
            y: 0
          }), cc.tween(t).delay(.1).to(.1, {
            opacity: 0
          })).call(function () {
            n();
            e && (t.scale = 1);
            o && (t.active = false);
          }).start();
        } else {
          console.error("closePageBasicAni 节点未激活");
          return void i();
        }
      } else {
        console.error("closePageBasicAni 节点为空 或 不可用");
        return void i();
      }
    });
  };
  return _ctor;
}(zqcc_frameNamespace.default.zqcc_ServiceBase);
exports.default = def_uiService;